#pragma once

/*
 * raft core grpc 服务类
 */

#include <grpcpp/server.h>

#include "bq_log/bq_log.h"
#include "raft_utils/Config.h"
#include "state_machine/StateMachine.h"

namespace raft::core {
    class RaftCoreGrpc {
    public:
        RaftCoreGrpc() : log(bq::log::get_log_by_name(utils::Config::getInstance()->get_log_name())) {}

        void start(std::shared_ptr<state_machine::StateMachine> state_machine,
                   std::shared_ptr<utils::Command> command);

        void stop();

    private:
        std::unique_ptr<grpc::Server> server_;

        bq::log log;
    };
}// namespace raft::core